package com.compass.mobile.ui.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.compass.mobile.R
import com.compass.mobile.models.BannerData
import com.compass.mobile.ui.adapter.HosBannerAdapter.BannerViewHolder
import com.youth.banner.adapter.BannerAdapter
import loadResRound
import setUrlRound

/**
 * Description：
 * Date:2024/8/13 10:34
 */
 class HosBannerAdapter //设置数据，也可以调用banner提供的方法,或者自己在adapter中实现
    (mDatas: List<BannerData?>?, private val context: Context) :
    BannerAdapter<BannerData?, BannerViewHolder>(mDatas) {
    //创建ViewHolder，可以用viewType这个字段来区分不同的ViewHolder
    override fun onCreateHolder(parent: ViewGroup, viewType: Int): BannerViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_banner, parent, false)
        return BannerViewHolder(view)
    }

    override fun onBindView(
        holder: BannerViewHolder?,
        data: BannerData?,
        position: Int,
        size: Int
    ) {
        holder?.imageView?.loadResRound(data?.resId,20)
    }




    inner class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var imageView: ImageView = view.findViewById(R.id.imgBanner)
    }
}
